/**
 * Created by Simon on 2017/4/11.
 */

$(function () {
  var vm = new Vue({
    el: '#certification-container',
    data: {
      isFormShow: false,
      editingId: -1,
      editingItem: {
        id: '',
        cnName: '',
        enName: '',
        spaName: '',
        updateTime: '',
        status: 1,
        imageUrl: ''
      }
    },
    methods: {
      onEditClick: function (id) {
        console.log('id', id);
        $.get(`/manage/getCertificationById?id=${id}`, (res) => {
          this.editingId = id;
          this.isFormShow = true;
          this.editingItem = res;
        });
      },
      onDeleteClick: function (id) {
        $.get(`/manage/deleteCertificationById?id=${id}`, (res) => {
          console.log('res', res);
          window.location.reload();
        });
      },
      onSubmitClick: function () {
        var form = this.$refs['certification-form'];
        form.submit();
      },
      onAddCertificationClick: function () {
        this.isFormShow = true;
      }
    },
    computed: {
      isSubmitEnabled: function () {
        return this.cnName && this.enName && this.spaName
      }
    }
  });
});